package com.medeiros.upmoney.model;

import android.graphics.Color;

/**
 * Status de um Meta
 * @author Medeiros
 */
public enum Status {

	CONFORTAVEL(Color.GREEN),
	CRITICO(Color.RED),
	ALERTA(Color.YELLOW);

	private static final double percAlerta = 0.1;
	private int color;
	
	private Status(int color) {
		this.color = color;
	}

	public static Status findStatus(Limite meta){
		double diff = meta.getPercentualValor().doubleValue() -  meta.getPercentualGasto().doubleValue();
		if(diff <0){
			return CRITICO;
		}
		
		double dezPerMeta = percAlerta * meta.getPercentualValor().doubleValue();
		if(diff < dezPerMeta){
			return ALERTA;
		}else{
			return CONFORTAVEL;
		}
	}
	
	public int getColor(){
		return color;
	}
}
